#!/bin/bash

set -e

do_ldconfig() {
  # left-hand term originates from ENABLE_LDCONFIG = ON/OFF at package build
  if [ "@ENABLE_LDCONFIG@" == "ON" ]; then
    echo @CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@ > /etc/ld.so.conf.d/x86_64-librocm_smi_lib.conf
    ldconfig
  fi
}

case "$1" in
  ( configure )
    do_ldconfig
  ;;
  ( abort-upgrade | abort-remove | abort-deconfigure )
    echo "$1"
  ;;
  ( * )
    exit 0
  ;;
esac
